package cn.itcast.java.apis;

/**
 * Author itcast
 * Date 2021/10/9 17:38
 * Desc TODO
 */
public class StringBuilderDemo04 {
    public static void main(String[] args) {
        //将字符串和StringBuilder相互转换
        String str = "abc";
        //转换成 StringBuilder
        StringBuilder stringBuilder = new StringBuilder(str);
        //将StringBuilder转换成String
        String s = stringBuilder.toString();
        //增加字符
        String result = stringBuilder
                .append('d')
                .append("xyz")
                .insert(stringBuilder.length() - 1, "@")
                .toString();
        System.out.println(result);
    }
}
